package life;

public class Coordinate
{

	final static int RANDOM=0;
	final static int VELOCITY=1;
	
	double x;
	double y;
	
	public Coordinate(double x, double y)
	{
		this.x = x;
		this.y = y;
	}
	public Coordinate(int mode, World w){
		
		if(mode==RANDOM)
		{
			x=Math.random()*w.extension.x;
			y=Math.random()*w.extension.y;
		}
	}
	
	public Coordinate(int mode, double	maxV){
		
		if(mode==VELOCITY)
		{
			double angle= Math.random()*Math.PI;
			//double v= Math.random()*maxV;
			x=Math.cos(angle)*maxV;
			y=Math.sin(angle)*maxV;
		}
	}

	public double squareDistance(Coordinate c)
	{
		return(x-c.x)*(x-c.x)+(y-c.y)*(y-c.y);
	}
	
	

	public double distance(Coordinate c)
	{
		return Math.sqrt(squareDistance(c));
	}
	@Override
	public String toString()
	{
		return "[" + (int)x + "," + (int)y + "]";
	}
	public double getX()
	{
		return x;
	}
	public void setX(double x)
	{
		this.x = x;
	}
	public double getY()
	{
		return y;
	}
	public void setY(double y)
	{
		this.y = y;
	}
	
	
	
	

}
